package cn.tedu.day08;
/**
 * 修改下面代码的编译

 */
public class Test02 {
    public static void main(String[] args) {
//		Thread t1 = new Thread() {
//			Foo.dosome();
//		};
//		Thread t2 = new Thread() {
//			Foo.dosome();
//		};
//		t1.start();
//		t2.start();
        //重写run方法来定义线程
        Thread t1 = new Thread() {
            public void run() {
                Foo.dosome();
            }
        };
        Thread t2 = new Thread() {
            public void run() {
                Foo.dosome();
            }
        };
        t1.start();
        t2.start();
    }
}

class Foo{
    public static void dosome() {
//		synchronized (this) {
//			System.out.println("hello!");
//		}

        //synchronized (this) { //静态方法中看不到this
        synchronized (Foo.class) {
            System.out.println("hello!");
        }
    }
}